/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.CardLayout;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import model.Curso;
import model.Disciplina;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import model.Usuario;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Date;

/**
 *
 * @author Lucas
 */
public class EntradaGUI extends javax.swing.JFrame {

    private static final String PERSISTENCE_UNIT_NAME = "ea975entradaPU";
    private static EntityManagerFactory factory;

    /**
     * Creates new form EntradaGUI
     */
    public EntradaGUI() {

        initComponents();
        try {
            String host = "jdbc:derby://localhost:1527/GRUPO6";
            String uName = "";
            String uPass = "";
            Connection con = DriverManager.getConnection(host, uName, uPass);
        } catch (SQLException ex) {
            appendToFile(ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        senhaIncorreta = new javax.swing.JDialog();
        ok = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        cadastroExistente = new javax.swing.JDialog();
        jLabel18 = new javax.swing.JLabel();
        fechar = new javax.swing.JButton();
        cadastroRealizado = new javax.swing.JDialog();
        jLabel19 = new javax.swing.JLabel();
        fecharRealizado = new javax.swing.JButton();
        usuarioInexistente = new javax.swing.JDialog();
        jLabel21 = new javax.swing.JLabel();
        fecharUserInex = new javax.swing.JButton();
        erroLogin = new javax.swing.JDialog();
        jLabel20 = new javax.swing.JLabel();
        fecharLogInvalid = new javax.swing.JButton();
        jLabel22 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        painelPrincipal = new javax.swing.JPanel();
        painelAuth = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        login = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        senha = new javax.swing.JPasswordField();
        entrar = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        painelOpcoes = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        label1 = new java.awt.Label();
        jComboBox2 = new javax.swing.JComboBox();
        jPanel6 = new javax.swing.JPanel();
        label2 = new java.awt.Label();
        jPanel2 = new javax.swing.JPanel();
        jCheckBox2 = new javax.swing.JCheckBox();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jButton1 = new javax.swing.JButton();
        painelEletivas = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jButton2 = new javax.swing.JButton();
        painelRestantes = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        cadastro = new javax.swing.JPanel();
        cadastroSenha = new javax.swing.JPasswordField();
        cadastroRA = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        cadastroNome = new javax.swing.JTextField();
        botaoCadastrar = new javax.swing.JButton();
        limparCadastro = new javax.swing.JButton();
        restantesButton = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        eletivasButton = new javax.swing.JButton();
        myOptionsButton = new javax.swing.JButton();
        sair = new javax.swing.JButton();

        jFrame1.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 612, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 426, Short.MAX_VALUE)
        );

        senhaIncorreta.setAlwaysOnTop(true);
        senhaIncorreta.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        senhaIncorreta.setMinimumSize(new java.awt.Dimension(130, 100));

        ok.setText("Ok");
        ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("Senha Incorreta!");

        javax.swing.GroupLayout senhaIncorretaLayout = new javax.swing.GroupLayout(senhaIncorreta.getContentPane());
        senhaIncorreta.getContentPane().setLayout(senhaIncorretaLayout);
        senhaIncorretaLayout.setHorizontalGroup(
            senhaIncorretaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(senhaIncorretaLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(ok)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(senhaIncorretaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                .addContainerGap())
        );
        senhaIncorretaLayout.setVerticalGroup(
            senhaIncorretaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(senhaIncorretaLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ok)
                .addContainerGap())
        );

        cadastroExistente.setMaximumSize(new java.awt.Dimension(100, 100));
        cadastroExistente.setMinimumSize(new java.awt.Dimension(100, 100));

        jLabel18.setText("Cadastro já existente!");

        fechar.setText("FECHAR");
        fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout cadastroExistenteLayout = new javax.swing.GroupLayout(cadastroExistente.getContentPane());
        cadastroExistente.getContentPane().setLayout(cadastroExistenteLayout);
        cadastroExistenteLayout.setHorizontalGroup(
            cadastroExistenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadastroExistenteLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(cadastroExistenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(cadastroExistenteLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(fechar))
                    .addComponent(jLabel18))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        cadastroExistenteLayout.setVerticalGroup(
            cadastroExistenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadastroExistenteLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fechar)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        cadastroRealizado.setPreferredSize(new java.awt.Dimension(100, 100));

        jLabel19.setText("Cadastro Realizado!");

        fecharRealizado.setText("FECHAR");

        javax.swing.GroupLayout cadastroRealizadoLayout = new javax.swing.GroupLayout(cadastroRealizado.getContentPane());
        cadastroRealizado.getContentPane().setLayout(cadastroRealizadoLayout);
        cadastroRealizadoLayout.setHorizontalGroup(
            cadastroRealizadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadastroRealizadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(cadastroRealizadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addGroup(cadastroRealizadoLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(fecharRealizado)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        cadastroRealizadoLayout.setVerticalGroup(
            cadastroRealizadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadastroRealizadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fecharRealizado)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        usuarioInexistente.setMinimumSize(new java.awt.Dimension(100, 100));

        jLabel21.setText("Usuário Inexistente!");

        fecharUserInex.setText("FECHAR");
        fecharUserInex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharUserInexActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout usuarioInexistenteLayout = new javax.swing.GroupLayout(usuarioInexistente.getContentPane());
        usuarioInexistente.getContentPane().setLayout(usuarioInexistenteLayout);
        usuarioInexistenteLayout.setHorizontalGroup(
            usuarioInexistenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(usuarioInexistenteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(usuarioInexistenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(usuarioInexistenteLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(fecharUserInex))
                    .addComponent(jLabel21))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        usuarioInexistenteLayout.setVerticalGroup(
            usuarioInexistenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(usuarioInexistenteLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fecharUserInex)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        erroLogin.setMinimumSize(new java.awt.Dimension(180, 180));

        jLabel20.setText("Login Inválido!");

        fecharLogInvalid.setText("FECHAR");
        fecharLogInvalid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharLogInvalidActionPerformed(evt);
            }
        });

        jLabel22.setText("Correto: 123456 (Exemplo)");

        javax.swing.GroupLayout erroLoginLayout = new javax.swing.GroupLayout(erroLogin.getContentPane());
        erroLogin.getContentPane().setLayout(erroLoginLayout);
        erroLoginLayout.setHorizontalGroup(
            erroLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(erroLoginLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(erroLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(erroLoginLayout.createSequentialGroup()
                        .addComponent(jLabel22)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(erroLoginLayout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(fecharLogInvalid)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        erroLoginLayout.setVerticalGroup(
            erroLoginLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(erroLoginLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel20)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel22)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fecharLogInvalid)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(51, 0, 255));

        jLabel2.setFont(new java.awt.Font("Ebrima", 0, 18)); // NOI18N
        jLabel2.setText(" Grupo 6");

        painelPrincipal.setLayout(new java.awt.CardLayout());

        painelAuth.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel10.setLayout(new java.awt.GridLayout(2, 2));

        jLabel8.setText("username");
        jPanel10.add(jLabel8);

        login.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        login.setText("login");
        login.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginActionPerformed(evt);
            }
        });
        jPanel10.add(login);

        jLabel5.setText("senha");
        jPanel10.add(jLabel5);

        senha.setText("senha");
        senha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                senhaActionPerformed(evt);
            }
        });
        jPanel10.add(senha);

        entrar.setText("ENTRAR");
        entrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                entrarActionPerformed(evt);
            }
        });

        jButton4.setText("CADASTRAR-SE");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel9.setText("Usuário Novo?");

        javax.swing.GroupLayout painelAuthLayout = new javax.swing.GroupLayout(painelAuth);
        painelAuth.setLayout(painelAuthLayout);
        painelAuthLayout.setHorizontalGroup(
            painelAuthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelAuthLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(entrar)
                .addGap(85, 85, 85))
            .addGroup(painelAuthLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelAuthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelAuthLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        painelAuthLayout.setVerticalGroup(
            painelAuthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelAuthLayout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(entrar)
                .addGap(94, 94, 94)
                .addGroup(painelAuthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton4)
                    .addComponent(jLabel9))
                .addGap(140, 140, 140))
        );

        painelPrincipal.add(painelAuth, "cardAuth");

        painelOpcoes.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);

        jPanel4.setBackground(new java.awt.Color(102, 255, 102));
        jPanel4.setLayout(new java.awt.BorderLayout());

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel3.setBackground(new java.awt.Color(153, 153, 255));
        jLabel3.setFont(new java.awt.Font("Kalinga", 0, 24)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Selecione o seu Curso:");

        label1.setText("Curso Atual:");

        factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

        EntityManager em = factory.createEntityManager();

        List<Curso> result
        = em.createNamedQuery("Curso.findAll").getResultList();

        for( int i=0;i< result.size();i++ ){
            jComboBox2.addItem(result.get(i));
        }
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(306, 306, 306))
        );

        jPanel4.add(jPanel1, java.awt.BorderLayout.CENTER);

        painelOpcoes.addTab("Curso", jPanel4);

        jPanel6.setBackground(new java.awt.Color(255, 255, 102));

        label2.setText("Selecione as Disciplinas que você já cursou");

        jPanel2.setLayout(new java.awt.BorderLayout());

        jCheckBox2.setText("jCheckBox2");
        jPanel2.add(jCheckBox2, java.awt.BorderLayout.CENTER);

        jCheckBox3.setText("jCheckBox3");
        jPanel2.add(jCheckBox3, java.awt.BorderLayout.PAGE_START);

        jCheckBox4.setText("jCheckBox4");
        jPanel2.add(jCheckBox4, java.awt.BorderLayout.PAGE_END);

        jButton1.setText("Registrar");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(100, 100, 100)
                .addComponent(jButton1)
                .addGap(100, 100, 100))
        );

        painelOpcoes.addTab("Disciplinas Cursadas", jPanel6);

        painelPrincipal.add(painelOpcoes, "cardOptions");

        painelEletivas.setBackground(new java.awt.Color(153, 153, 255));
        painelEletivas.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        painelEletivas.setEnabled(false);
        painelEletivas.setOpaque(false);

        jPanel8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel8.setLayout(new java.awt.BorderLayout());

        jLabel6.setText("Disciplina 1");
        jPanel8.add(jLabel6, java.awt.BorderLayout.PAGE_START);

        jLabel7.setText("Disciplina 2");
        jPanel8.add(jLabel7, java.awt.BorderLayout.PAGE_END);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Disciplinas Eletivas de dado Curso");

        jLabel11.setText("Selecione o Curso");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jButton2.setText("OK");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout painelEletivasLayout = new javax.swing.GroupLayout(painelEletivas);
        painelEletivas.setLayout(painelEletivasLayout);
        painelEletivasLayout.setHorizontalGroup(
            painelEletivasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelEletivasLayout.createSequentialGroup()
                .addGroup(painelEletivasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelEletivasLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(painelEletivasLayout.createSequentialGroup()
                        .addGroup(painelEletivasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(painelEletivasLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(painelEletivasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(painelEletivasLayout.createSequentialGroup()
                                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButton2)
                                        .addGap(25, 25, 25))))
                            .addGroup(painelEletivasLayout.createSequentialGroup()
                                .addGap(114, 114, 114)
                                .addComponent(jLabel11)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        painelEletivasLayout.setVerticalGroup(
            painelEletivasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelEletivasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelEletivasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2))
                .addGap(33, 33, 33)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(140, 140, 140))
        );

        painelPrincipal.add(painelEletivas, "cardEletivas");

        painelRestantes.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel12.setText("Disciplinas Restantes");

        jLabel13.setText("O aluno ainda precisa cursas essas disciplinas");

        javax.swing.GroupLayout painelRestantesLayout = new javax.swing.GroupLayout(painelRestantes);
        painelRestantes.setLayout(painelRestantesLayout);
        painelRestantesLayout.setHorizontalGroup(
            painelRestantesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelRestantesLayout.createSequentialGroup()
                .addGroup(painelRestantesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelRestantesLayout.createSequentialGroup()
                        .addGap(88, 88, 88)
                        .addComponent(jLabel12))
                    .addGroup(painelRestantesLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel13)))
                .addContainerGap(78, Short.MAX_VALUE))
        );
        painelRestantesLayout.setVerticalGroup(
            painelRestantesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelRestantesLayout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20)
                .addComponent(jLabel13))
        );

        painelPrincipal.add(painelRestantes, "cardRestantes");

        cadastroSenha.setText("senha");

        cadastroRA.setText("RA");
        cadastroRA.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        cadastroRA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastroRAActionPerformed(evt);
            }
        });

        jLabel15.setText("RA:");

        jLabel16.setText("Senha:");

        jLabel17.setText("Nome:");

        cadastroNome.setText("Nome");

        botaoCadastrar.setText("CADASTRAR");
        botaoCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoCadastrarActionPerformed(evt);
            }
        });

        limparCadastro.setText("LIMPAR CADASTRO");
        limparCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limparCadastroActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout cadastroLayout = new javax.swing.GroupLayout(cadastro);
        cadastro.setLayout(cadastroLayout);
        cadastroLayout.setHorizontalGroup(
            cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadastroLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(cadastroLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cadastroRA, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(178, 178, 178))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, cadastroLayout.createSequentialGroup()
                        .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel17)
                            .addComponent(jLabel16))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(cadastroLayout.createSequentialGroup()
                                .addComponent(cadastroSenha)
                                .addGap(178, 178, 178))
                            .addGroup(cadastroLayout.createSequentialGroup()
                                .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(cadastroLayout.createSequentialGroup()
                                        .addComponent(botaoCadastrar)
                                        .addGap(18, 18, 18)
                                        .addComponent(limparCadastro))
                                    .addComponent(cadastroNome, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(23, Short.MAX_VALUE))))))
        );
        cadastroLayout.setVerticalGroup(
            cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(cadastroLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(cadastroRA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(cadastroSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(cadastroNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(cadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoCadastrar)
                    .addComponent(limparCadastro))
                .addContainerGap(136, Short.MAX_VALUE))
        );

        painelPrincipal.add(cadastro, "cardCadastro");

        restantesButton.setText("Disciplinas Restantes");
        restantesButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        restantesButton.setEnabled(false);
        restantesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                restantesButtonActionPerformed(evt);
            }
        });

        jLabel4.setText("Apresentação");

        jLabel10.setText("Entrada");

        eletivasButton.setText("Eletivas do Curso");
        eletivasButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        eletivasButton.setEnabled(false);
        eletivasButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eletivasButtonActionPerformed(evt);
            }
        });

        myOptionsButton.setText("Minhas Opções");
        myOptionsButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        myOptionsButton.setEnabled(false);
        myOptionsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                myOptionsButtonActionPerformed(evt);
            }
        });

        sair.setText("SAIR");
        sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(painelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 315, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel10))
                                .addGap(40, 40, 40))
                            .addComponent(myOptionsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(restantesButton, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                            .addComponent(eletivasButton, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                            .addComponent(sair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(120, 120, 120)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(24, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(myOptionsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(restantesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(eletivasButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(sair))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(painelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 302, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(20, 20, 20))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void loginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_loginActionPerformed

    private void senhaActionPerformed(java.awt.event.ActionEvent evt) {
    }

    private void entrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_entrarActionPerformed
        // TODO  - checar se usuário e senha estão no banco de usuários
        String s = senha.getPassword().toString();
        factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

        EntityManager em = factory.createEntityManager();
        try {
            Integer id = Integer.parseInt(login.getText());

            try {
                List<Usuario> result = em.createNamedQuery("Usuario.findById").setParameter("id", id).getResultList();
                String pwd = result.get(0).getSenha();

                if (s.equals(pwd)) {
                    myOptionsButton.setEnabled(true);
                    eletivasButton.setEnabled(true);
                    restantesButton.setEnabled(true);
                    CardLayout cards = (CardLayout) painelPrincipal.getLayout();
                    cards.show(painelPrincipal, "cardOptions");
                } else {
                    senhaIncorreta.show();
                }
            } catch (Exception ex) {
                usuarioInexistente.show();
                //appendToFile(ex);
            }
        } catch (NumberFormatException ex) {
            erroLogin.show();
            appendToFile(ex);
        }
    }//GEN-LAST:event_entrarActionPerformed

    private void restantesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restantesButtonActionPerformed
        CardLayout cardLayout = (CardLayout) painelPrincipal.getLayout();
        cardLayout.show(painelPrincipal, "cardRestantes");
    }//GEN-LAST:event_restantesButtonActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    }//GEN-LAST:event_jButton2ActionPerformed

    private void myOptionsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_myOptionsButtonActionPerformed
        CardLayout cardLayout = (CardLayout) painelPrincipal.getLayout();
        cardLayout.show(painelPrincipal, "cardOptions");
    }//GEN-LAST:event_myOptionsButtonActionPerformed

    private void eletivasButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eletivasButtonActionPerformed
        CardLayout cardLayout = (CardLayout) painelPrincipal.getLayout();
        cardLayout.show(painelPrincipal, "cardEletivas");
    }//GEN-LAST:event_eletivasButtonActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        // TODO add your handling code here:
        // Create the EntityManagerFactory


    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
        // TODO add your handling code here:
        senhaIncorreta.hide();
    }//GEN-LAST:event_okActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        CardLayout cardLayout = (CardLayout) painelPrincipal.getLayout();
        cardLayout.show(painelPrincipal, "cardCadastro");
    }//GEN-LAST:event_jButton4ActionPerformed

    private void botaoCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoCadastrarActionPerformed
        // TODO add your handling code here:
        factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

        EntityManager em = factory.createEntityManager();

        Integer ra = Integer.parseInt(cadastroRA.getText());

        Usuario cadastro = new Usuario(ra, cadastroNome.getText(), cadastroSenha.getText());
        System.out.println(ra + cadastroNome.getText() + cadastroSenha.getText());

        List<Usuario> result = em.createNamedQuery("Usuario.findById").setParameter("id", ra).getResultList();

        if (result.isEmpty()) {

            em.getTransaction().begin();
            em.persist(cadastro);
            em.getTransaction().commit();
            cadastroRealizado.show();
            myOptionsButton.setEnabled(false);
            eletivasButton.setEnabled(false);
            restantesButton.setEnabled(false);
            CardLayout cards = (CardLayout) painelPrincipal.getLayout();
            cards.show(painelPrincipal, "cardAuth");

        } else {
            cadastroExistente.show();
        }
        em.close();
    }//GEN-LAST:event_botaoCadastrarActionPerformed

    private void cadastroRAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastroRAActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cadastroRAActionPerformed

    private void limparCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limparCadastroActionPerformed
        // TODO add your handling code here:
        cadastroNome.setText(null);
        cadastroSenha.setText(null);
        cadastroRA.setText(null);
    }//GEN-LAST:event_limparCadastroActionPerformed

    private void fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharActionPerformed
        // TODO add your handling code here:
        cadastroExistente.hide();
    }//GEN-LAST:event_fecharActionPerformed

    private void sairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairActionPerformed
        // TODO add your handling code here:
        myOptionsButton.setEnabled(false);
        eletivasButton.setEnabled(false);
        restantesButton.setEnabled(false);
        CardLayout cards = (CardLayout) painelPrincipal.getLayout();
        cards.show(painelPrincipal, "cardAuth");
    }//GEN-LAST:event_sairActionPerformed

    private void fecharLogInvalidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharLogInvalidActionPerformed
        // TODO add your handling code here:
        erroLogin.hide();
    }//GEN-LAST:event_fecharLogInvalidActionPerformed

    private void fecharUserInexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharUserInexActionPerformed
        // TODO add your handling code here:
        usuarioInexistente.hide();
    }//GEN-LAST:event_fecharUserInexActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EntradaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            appendToFile(ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EntradaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            appendToFile(ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EntradaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            appendToFile(ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EntradaGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            appendToFile(ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EntradaGUI().setVisible(true);
            }
        });
    }

    public static void appendToFile(Exception ex) {
        Date d = new Date();
        try {
            FileWriter fstream = new FileWriter("exception.txt", true);
            BufferedWriter out = new BufferedWriter(fstream);
            PrintWriter pWriter = new PrintWriter(out, true);
            pWriter.println(d + ": ");
            pWriter.println("Class: EntradaGUI");
            ex.printStackTrace(pWriter);
            pWriter.println();
        } catch (Exception ie) {
            throw new RuntimeException("Could not write Exception to file", ie);
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoCadastrar;
    private javax.swing.JPanel cadastro;
    private javax.swing.JDialog cadastroExistente;
    private javax.swing.JTextField cadastroNome;
    private javax.swing.JTextField cadastroRA;
    private javax.swing.JDialog cadastroRealizado;
    private javax.swing.JPasswordField cadastroSenha;
    private javax.swing.JButton eletivasButton;
    private javax.swing.JButton entrar;
    private javax.swing.JDialog erroLogin;
    private javax.swing.JButton fechar;
    private javax.swing.JButton fecharLogInvalid;
    private javax.swing.JButton fecharRealizado;
    private javax.swing.JButton fecharUserInex;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private java.awt.Label label1;
    private java.awt.Label label2;
    private javax.swing.JButton limparCadastro;
    private javax.swing.JTextField login;
    private javax.swing.JButton myOptionsButton;
    private javax.swing.JButton ok;
    private javax.swing.JPanel painelAuth;
    private javax.swing.JPanel painelEletivas;
    private javax.swing.JTabbedPane painelOpcoes;
    private javax.swing.JPanel painelPrincipal;
    private javax.swing.JPanel painelRestantes;
    private javax.swing.JButton restantesButton;
    private javax.swing.JButton sair;
    private javax.swing.JPasswordField senha;
    private javax.swing.JDialog senhaIncorreta;
    private javax.swing.JDialog usuarioInexistente;
    // End of variables declaration//GEN-END:variables
}
